package com.village.zpark.service.impl;

import com.village.zpark.mapper.AdminMapper;
import com.village.zpark.pojo.Admin;
import com.village.zpark.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

@Service
@Transactional
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper adminMapper;
    @Override
    public Admin login(Admin admin) {
        //根据用户名查询用户
        Example example = new Example(Admin.class);
        example.createCriteria().andEqualTo("adminname",admin.getAdminname());
        example.createCriteria().andEqualTo("password",admin.getPassword());
        Admin admin2 = adminMapper.selectOneByExample(example);
        return adminMapper.selectByPrimaryKey(admin2.getId());
    }

    @Override
    public boolean add(Admin admin) {
        return adminMapper.insert(admin)>0;
    }

}
